<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('添加订单')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-profitSbOrder-addOrder">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">出款方式：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control m-b" required>
                        <option value="2">代付对私</option>
                        <option value="1">代付对公</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "agentInfo/profitSbOrder"
        $("#form-profitSbOrder-addOrder").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                //$.operate.save(prefix + "/addOrder", $('#form-profitSbOrder-addOrder').serialize());
                var formData = new FormData();
                var type=$("[name='type']").val();
                formData.append("type",type);
                $.ajax({
                    url : prefix + "/addOrder",
                    type: 'POST',
                    data: formData,
                    cache: false,
                    contentType: false,
                    processData: false,
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                        $.modal.disable();
                    },
                    success : function(result) {
                        if (result.code == web_status.SUCCESS) {
                            var parent = window.parent;
                            if (parent.table.options.type == table_type.bootstrapTable) {
                                $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
                            } else if (parent.table.options.type == table_type.bootstrapTreeTable) {
                                $.modal.close();
                                parent.$.modal.msgSuccess(result.msg);
                                parent.$.treeTable.refresh();
                            } else {
                                $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
                            }
                        } else if (result.code == web_status.WARNING) {
                            $.modal.alertWarning(result.msg)
                        }  else {
                            $.modal.alertError(result.msg);
                        }
                        $.modal.closeLoading();
                        $.modal.enable();
                    },
                    error : function(result) {
                        $.modal.alertError(result.msg);
                    }
                });
            }
        }
    </script>
</body>
</html>